package com.yuntcm.group6.med_booking.controller;

import com.yuntcm.group6.med_booking.entity.User;
import com.yuntcm.group6.med_booking.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/register")
    public boolean register(@RequestBody User user) {
        return userService.register(user);
    }

    @PostMapping("/login")
    public User login(@RequestBody User user) {
        return userService.login(user.getUsername(), user.getPassword());
    }

    @PostMapping("/updateProfile")
    public boolean updateProfile(@RequestBody User user) {
        return userService.updateProfile(user);
    }
}